package com.sy.blog.controller;


import com.sy.blog.service.CategoryService;
import com.sy.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("categorys")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 写文章时展示文章所有分类
     * @return
     */
    @GetMapping
    public Result listCategories() {
        return categoryService.findAll();
    }

    /**
     * 详细的文章分类
     * @return
     */
    @GetMapping("detail")
    public Result listCategoriesDetail() {
        return categoryService.findAllDetail();
    }

    @GetMapping("detail/{id}")
    public Result listCategoriesDetailById(@PathVariable("id") Long id) {
        return categoryService.findAllDetailById(id);
    }

}
